/********************************************************************************
 *      Copyright:  (C) 2022 guoyi<675088383@qq.com>
 *                  All rights reserved.
 *
 *       Filename:  zlog_api.h
 *    Description:  This head file 
 *
 *        Version:  1.0.0(26/12/21)
 *         Author:  guoyi<675088383@qq.com>
 *      ChangeLog:  1, Release initial version on "12/12/21 07:26:59"
 *                 
 ********************************************************************************/

#include "zlog.h"
 
#define ESC_START       "\033["
#define ESC_END         "\033[0m"
#define COLOR_FATAL     "31;40;5m"
#define COLOR_ALERT     "31;40;1m"
#define COLOR_CRIT      "31;40;1m"
#define COLOR_ERROR     "35;40;1m"
#define COLOR_WARN      "33;40;1m"
#define COLOR_NOTICE    "34;40;1m"
#define COLOR_INFO      "32;40;1m"
#define COLOR_DEBUG     "36;40;1m"
#define COLOR_TRACE     "37;40;1m"
 
extern zlog_category_t * zc;
extern int log_init();
extern void log_fini();
 
#define log_fatal(fmt,args...)         \
        zlog(zc, __FILE__, sizeof(__FILE__)-1, \
                    __func__, sizeof(__func__)-1, __LINE__, \
                        ZLOG_LEVEL_FATAL, ESC_START COLOR_FATAL fmt ESC_END, ##args)
 
    
#define log_error(fmt , args...)    \
        zlog(zc, __FILE__, sizeof(__FILE__)-1, \
                    __func__, sizeof(__func__)-1, __LINE__, \
                        ZLOG_LEVEL_ERROR, ESC_START COLOR_ERROR fmt ESC_END, ##args)
    
#define log_warn(fmt, args...)        \
        zlog(zc, __FILE__, sizeof(__FILE__)-1, \
                    __func__, sizeof(__func__)-1, __LINE__, \
                        ZLOG_LEVEL_WARN, ESC_START COLOR_WARN fmt ESC_END, ##args)
    
#define log_notice(fmt , args...)    \
        zlog(zc, __FILE__, sizeof(__FILE__)-1, \
                    __func__, sizeof(__func__)-1, __LINE__, \
                        ZLOG_LEVEL_NOTICE, ESC_START COLOR_NOTICE fmt ESC_END, ##args)
    
#define log_info(fmt,args...)         \
        zlog(zc, __FILE__, sizeof(__FILE__)-1, \
                    __func__, sizeof(__func__)-1, __LINE__, \
                        ZLOG_LEVEL_INFO, ESC_START COLOR_INFO fmt ESC_END, ##args)
    
#define log_debug(fmt , args...)    \
        zlog(zc, __FILE__, sizeof(__FILE__)-1, \
                    __func__, sizeof(__func__)-1, __LINE__, \
                        ZLOG_LEVEL_DEBUG, ESC_START COLOR_DEBUG fmt ESC_END, ##args)
